/* 位运算
* 1.龟速乘
    加法实现乘法

*/
#define DEBUG
#pragma GCC optimize("O1,O2,O3,Ofast")
#pragma GCC optimize("no-stack-protector,unroll-loops,fast-math,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,ssse3")

#include <iostream>
using namespace std;
#define int long long
const int N = 64;
int qmi(int base, int index, int MOD)
{
    int res = 1;
    while(index)
    {
        if(index&1) res = (res + base) % MOD;
        base = (base*base) % MOD;
        index >>= 1;
    }
    return res;
}
 
int mul(int a, int b, int MOD)
{
    int res = 0;
    while(b)
    {
        if(b&1) res = (res + a) % MOD;
        a = (a+a)%MOD;
        b >>= 1;
    }
    return res;
}

signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
    #else
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #endif
    
    int a, b, MOD;
    cin >> a >> b >> MOD;
    cout << mul(a, b, MOD) << endl;
    return 0;
}